package immutablecollections.functions;

import immutablecollections.*;

class Function1Impl<O> implements Function1<O>
{
    final private Invoker<O> invoker;

    public Function1Impl(Invoker<O> invoker)
    {
        this.invoker = invoker;
    }

    public Function1Impl(Object firstArg, Invoker<O> invoker)
    {
        this(new DelegateInvoker<O>(invoker, firstArg));
    }

    @Override
    public O invoke(Object arg1)
    {
        return invoker.invoke(ImList.on(arg1));
    }

    @Override
    public String toString()
    {
        return invoker.toString();
    }
}
